<script>
function onprofileOpen() {
    refreshGrid("sponsor");
}
</script>

<table>
<tr><td>
<table id="sponsors" class="admingrid">
</table>
<div id="profiles_pager"></div>
</td><td valign="top">
<div style="display:none;" id="sponsor_accept_form" class="adminform">
    <button name="spn_acceptchanges" id="" onclick="acceptsponsorChanges(this)">Accept changes</button>
    <button name="spn_rejectchanges" id="" onclick="rejectsponsorChanges(this)">Reject changes</button>
    <button name="spn_preview" id="" onclick="previewsponsor(this)">Preview new profile</button>
</div>
</td></tr>
</table>

<script>
grids.sponsors = {
    url : generateServiceUrl({
        admin : true,
        service : "getsponsorlist",
        page : "confirm"
    }),
    colNames : [
        "company_name"
    ],
    colModel : [
        { name : "company_name",   index : "company_name",   width : 350 },
    ],
    caption : "Company list"
};

function sponsors_selected(id) {
    jQuery("table#changelist").empty();
    callAdminService("confirm", "getchanges", {
        type : "profile",
        id : id
    }, {
        success : function(result) {
            jQuery("button[name='spn_acceptchanges']").attr("id", id);
            jQuery("button[name='spn_rejectchanges']").attr("id", id);
            jQuery("button[name='spn_preview']").attr("id", id);
            jQuery("#sponsor_accept_form").show("fade", {}, 300);
        }
    });
}

function profile_hpenglish_display(value) { return ["English homepage", value]; }
function profile_hphungarian_display(value) { return ["Hungarian homepage", value]; }
function profile_companyname_display(value) { return ["Company name", value]; }

function acceptsponsorChanges(item) {
    callAdminService("confirm", "acceptchanges", {
        type : "sponsor",
        id : item.id
    }, {
        success : function(result) {
            jQuery("#sponsor_accept_form").hide("fade", {}, 300);
            refreshGrid("sponsors");
        }
    });
}

function rejectsponsorChanges(item) {
    callAdminService("confirm", "rejectchanges", {
        type : "sponsor",
        id : item.id
    }, {
        success : function(result) {
            jQuery("#sponsor_accept_form").hide("fade", {}, 300);
            refreshGrid("sponsors");
        }
    });
}

function previewsponsor(item) {
    callHtmlService("companyprofile", "view", {
        type : "sponsor",
        id : item.id,
        displayType : "preview"
    }, {
        success : function(html) {
            openOverlay(700, 400, html);
        }
    });
}

</script>

